$(document).ready(function () {


    $('section').css({opacity: "0"});
    $('body').css({"overflowY": "hidden"});

    $("#nav-container,#mouse-container,.home-section,.footer").css({opacity: 0});

    /*loading*/




    var $wrap = document.getElementById('wrap');
    $wrap.appendChild(document.createElement('div'));

    // animate();

    function render() {

        var progress;

        animatestep = Math.max(0, Math.min(240, toend ? animatestep + 1 : animatestep - 4));
        acceleration = easing(animatestep, 0, 1, 240);

        if (acceleration > 0.35) {
            progress = (acceleration - 0.35) / 0.65;
            group.rotation.y = -Math.PI / 2 * progress;
            group.position.z = 50 * progress;
            progress = Math.max(0, (acceleration - 0.97) / 0.03);
            mesh.material.opacity = 1 - progress;
            ringcover.material.opacity = ring.material.opacity = progress;
            ring.scale.x = ring.scale.y = 0.5 + 0.1 * progress;
        }

        renderer.render(scene, camera);

    }

    function animate() {
        console.log("loading")
        mesh.rotation.x += rotatevalue + acceleration;
        render();
        requestAnimationFrame(animate);
    }

    function easing(t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    }

    //鼠标提示
    $(window).scroll(function () {
        $("#mouse-container").stop().animate({
            opacity: (jQuery(window).scrollTop() / 150) > 1 ? 0 : (1 - (jQuery(window).scrollTop() / 150))
        });
    });

    $(".learn-vizen-camera").mouseenter(
        function () {
            $(".learn-vizen").toggleClass("learn-vizen-hover");
        });

    $(".learn-vizen-camera").mouseleave(function () {
        $(".learn-vizen").toggleClass("learn-vizen-hover");
    });

    //初始化
    window.isImageLoad(function () {
        $(".loading").css({opacity: 0, transition: "opacity 2s", zIndex: -1});
        $('section').css({opacity: "1"});
        $('body').css({"overflowY": "scroll"});
        $("html,body").stop().animate({scrollTop: 0});
        $("#nav-container").css({
            opacity: 1,
            transform: 'translateY(0px)',
            transition: 'transform 1s,opacity 1s ease-in'
        })
        $("#mouse-container,.home-section,.footer").css({opacity: 1, transition: "opacity 1s"});
    });

    window.panoLoaded = function () {
        if (window.browserVertion == "10") {

        } else {
            $("#pano-cover").css({opacity: 0, transition: "opacity 2s"});
        }

    }

    var mySwiper = new Swiper('.about-partners', {
        direction: 'horizontal',
        autoplayDisableOnInteraction: false,
        pagination: '.pagination',
        paginationClickable: true,
        loop:true,
        autoplay: 3000,
    });


    $(".case-learn-more").click(function () {
        window.forwardTo("case.html?caseId=case-list-item-hotel");
    });

    //核心技术
    $("#core-tech-learn-more").click(function () {
        window.forwardTo("core.html", "type=matrix");
    });

    // //关于公司
    // var partnersGone = true;
    // $("#home-section-about").mousewheel(function (event, delta) {
    //     if (delta < 0 && partnersGone) {
    //         partnersGone = false;
    //         $("#about-partners-left").css({
    //             transform: "translate3d(0,0,0)",
    //             transition: "transform 1.5s ease-in-out"
    //         });
    //         $("#about-partners-right").css({
    //             transform: "translate3d(0,0,0)",
    //             transition: "transform 1.5s ease-in-out"
    //         });
    //     }
    // });
    //
    // //新闻动态
    // var newSwiper = new Swiper('.news-swiper', {
    //     direction: 'vertical',
    //     pagination: '.swiper-pagination',
    //     paginationClickable: true,
    //     autoplay: 5000,
    //     loop: true
    // });
    // $(".news-learn-more").click(function () {
    //     window.forwardTo("news.html")
    // });
    // $(".home-section-five").mousewheel(function (event, delta, deltaX, deltaY) {
    //     var translateValue = 0;
    //     if (delta < 0) {
    //         //向下滚动
    //         translateValue = event.offsetY / 18;
    //         $("#earth").css({
    //             "transition": "transform 1s ease-out",
    //             "transform": "translate3d(0," + translateValue + "px,0)"
    //         });
    //     } else {
    //         translateValue = translateValue - event.offsetY / 18;
    //         $("#earth").css({
    //             "transition": "transform 1s ease-out",
    //             "transform": "translate3d(0," + translateValue + "px,0)"
    //         });
    //     }
    // });
    // $(".home-section-five").mousewheel(function (event, delta, deltaX, deltaY) {
    //     var translateValue = 0;
    //     if (delta < 0) {
    //         //向下滚动
    //         translateValue = event.offsetY / 12;
    //         $("#minbg1,#minbg2,#minbg3").css({
    //             "transition": "transform 0.7s 0.4s ease-out",
    //             "transform": "translate3d(0," + translateValue + "px,0)"
    //         });
    //     } else {
    //         translateValue = translateValue - event.offsetY / 12;
    //         $("#minbg1,#minbg2,#minbg3").css({
    //             "transition": "transform 0.7s 0.4s ease-out",
    //             "transform": "translate3d(0," + translateValue + "px,0)"
    //         });
    //     }
    // })
    // 以下为Condy修改

    //滚动事件
    // if (window.browserVertion == "10") {
    //
    // } else {
    //     var changed = false;
    //     var showing = false;
    //     var distance = $("#home-section-case").offset().top;
    //     var distance1 = $("#divScroll").offset().top;
    //     var distance2 = $(".about-desc_1").offset().top;
    //     $(window).scroll(function () {
    //         if ($(window).scrollTop() >= distance && showing == false) {
    //             document.getElementById("matrix-show").setAttribute("src", "corematrix.html");
    //             showing = true;
    //             setTimeout("document.getElementById('hideLoading').style.display=\"none\"; ", 3000)
    //         } else if ($(window).scrollTop() > distance1 && $(window).scrollTop()< distance2 && changed == false) {
    //             changed = true;
    //             window.panoView.setAutoplayEnable(false);
    //             window.frames['matrix-show'].model3D && window.frames['matrix-show'].model3D.setAutoplayEnable(true);
    //             $("#hideLoading-1").hide();
    //         } else if ($(window).scrollTop() <= distance1 && changed == true) {
    //             changed = false;
    //             window.panoView.setAutoplayEnable(true);
    //             window.frames['matrix-show'].model3D && window.frames['matrix-show'].model3D.setAutoplayEnable(false);
    //         }
    //         else if ($(window).scrollTop() >= distance2 && changed == true) {
    //             changed = false;
    //             window.panoView.setAutoplayEnable(false);
    //             window.frames['matrix-show'].model3D && window.frames['matrix-show'].model3D.setAutoplayEnable(false);
    //         }
    //
    //     });
    //
    // }

});